@extends('default.layouts.adminPublic')
@section('title', '添加地标管理')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('/default/css/personal/place.css')}}">

    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/coll_place')}}">首页</a> &raquo; 添加地标管理
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->
    <div class="con">

        <div class="conMain">
            <div class="result_wrap">
                <div class="search">
                    <span style="margin-right: 20px;"><a href="{{url('admin/coll_place/create')}}"><i
                                    class="fa fa-plus"></i>添加地标</a></span>
                    <span><a href="{{url('admin/coll_place')}}"><i class="fa fa-recycle"></i>地标管理列表</a></span>
                </div>
                <div class="message"><h2>添加地标</h2></div>
            </div>
            <div class="conInfo">
                <div class="manage" style="padding: 0; margin-bottom: 10px;">
                    @if(count($errors)>0)
                        <div class="mark">
                            @if(is_object($errors))
                                @foreach($errors->all() as $error)
                                    <p>{{$error}}</p>
                                @endforeach
                            @else
                                <p>{{$errors}}</p>
                            @endif
                        </div>
                    @endif
                </div>
                <div class="conAddList">
                    <form method="post" action="{{url('admin/coll_place')}}" name="placeForm" id="placeForm"
                          onsubmit="return checkForm('#placeForm')">
                        {{csrf_field()}}
                        <dl>
                            <dt><i class="require">*</i>县/市/区：</dt>
                            <dd style="margin-top: 4px">
                                <input id="pid" name="pid" type="hidden" value="{{old('pid')}}">
                                <input id="province" name="province" type="hidden">
                                <div id="province_select" class="select"><span><a></a></span><i></i></div>
                                <input id="area" name="area" type="hidden">
                                <div id="area_select" class="select" style="margin-left: 5px;">
                                    <span><a></a></span><i></i></div>
                                <input id="city" name="city" type="hidden" value="">
                                <div id="city_select" class="select" style="margin-left: 5px;">
                                    <span><a></a></span><i></i></div>
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>地标名称：</dt>
                            <dd><input type="text" class="inpText" style="width:420px;" value="{{old('name')}}"
                                       name="name" id="name">
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>地标编号：</dt>
                            <dd><input type="text" class="inpText" style="width:420px;" value="{{old('cid')}}"
                                       name="cid" id="cid">
                                <span style="color: #ff4400">注：地标编号必须以当前县市区开头的8位数！</span>
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>地标经度：</dt>
                            <dd><input type="text" class="inpText" style="width:420px; float:left; margin-top:8px;" value="{{old('longitude')}}"
                                       name="longitude" id="longitude">
                                <input id="place_name" name="place_name" value="" type="hidden">
                                <span class="set_place" style="margin-top:7px;" id="set_place">设置地标(经纬度)</span>
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>地标纬度：</dt>
                            <dd><input type="text" class="inpText" style="width:420px;" value="{{old('latitude')}}"
                                       name="latitude" id="latitude">
                            </dd>
                        </dl>
                        <dl>
                            <dt>地标排序：</dt>
                            <dd><input type="text" class="inpText" style="width:420px;" value="{{old('sort')}}"
                                       name="sort" id="sort">
                            </dd>
                        </dl>
                        <dl>
                            <dt></dt>
                            <dd>
                                <input type="submit" class="sub" value="添加地标">
                                <input type="button" class="sub but" onclick="history.go(-1)" value="返回">
                            </dd>
                        </dl>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
    @endsection

    @section('footerjs')
    @parent
            <!--地区三级联动-->
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.select.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.select.area.js')}}"></script>
    {{--设置地标--}}
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.setPlaceTown.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.select.area.js')}}"></script>
    <script type="text/javascript">
        var placeForm = $("#placeForm");
        $(function(){
            //地区联动
            placeForm.find("#pid").selectArea({
                'province': $('#province'),
                'area': $('#area'),
                'city': $('#city'),
                selected: '{{old('pid')}}',
                callback: function(val, text){
                    placeForm.find("#cid").val(val);
                    placeForm.find("#cid").focus();
                }
            });
        });
        //设置地标
        $('.con').find('#placeForm').setPlaceTown({
            title: "设置地标",    		//设置地标经度
            longitude: "#longitude",    		//设置地标经度
            latitude: "#latitude", 				//设置地标纬度
            place_name: "#place_name",	         //设置地标名称
            set_place: "#set_place",       		//地标的点击按钮
            place_url: '/admin/place_map' 	    //地标地图url
        });
    </script>
@endsection